import pandas as pd
import numpy as np
from keras import Sequential
from keras.layers import Dense, Dropout
from keras.utils import np_utils

data = pd.read_csv("train/train.csv")

data = data.dropna(axis=0)
data = data.drop(["State", "Area Code", "Phone", "Int'l Plan", "VMail Plan"], axis=1)

data = np.array(data)

x_train = data[:2, :-1]
y_train = data[:2, -1]
x_test = data[2:, :-1]
y_test = data[2:, -1]

# mean = x_train.mean(axis=0)
# std = x_train.std(axis=0)
# print(std)
# exit(0)
#
# x_train = (x_train - mean) / std
#
# mean = x_test.mean(axis=0)
# std = x_test.std(axis=0)
# x_test = (x_test - mean) / std


y_train = np_utils.to_categorical(y_train, num_classes=2)
y_test = np_utils.to_categorical(y_test, num_classes=2)

model = Sequential()
model.add(Dense(512, input_shape=(x_train.shape[1],), activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(512, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(2, activation='softmax'))

model.compile(loss="categorical_crossentropy", optimizer="rmsprop", metrics=["accuracy"])
history = model.fit(x_train, y_train, batch_size=128, epochs=10, verbose=1, validation_split=0.1)

y_pre = model.predict(x_test)
y_pre = np.argmax(y_pre, axis=1)
y_pre = y_pre.T
print(y_pre)


np.argmax